Moving Pictures Experts Groups (MPEG) is an International Standards Organization (ISO) standard for compressing video data. Video compression is important in making video data files, such as full-length movies, more manageable for storage (e.g., in optical storage media), processing, and transmission. In general, MPEG compression is achieved by eliminating redundant and irrelevant information. Because video images typically consist of smooth regions of color across the screen, video information generally varies little in space and time. As such, a significant part of the video information in an image is predictable and therefore redundant. Hence, a first objective in MPEG compression is to remove the redundant information and leaving only the true or unpredictable information. On the other hand, irrelevant video image information is information that cannot be seen by the human eye under certain reasonable viewing conditions. For example, the human eye is less perceptive to noise at high spatial frequencies than noise at low spatial frequencies and less perceptive to loss of details immediately before and after a scene change. Accordingly, the second objective in MPEG compression is to remove irrelevant information. The combination of redundant information removal and irrelevant information removal allows for highly compressed video data files.
MPEG compression incorporates various well-known techniques to achieve the above objectives including: motion-compensated prediction, Discrete Cosine Transform (DCT), quantization, and Variable-Length Coding (VLC). DCT is an algorithm that converts pixel data into sets of spatial frequencies with associated coefficients. Due to the non-uniform distribution of the DCT coefficients wherein most of the non-zero DCT coefficients of an image tend to be located in a general area, VLC is used to exploit this distribution characteristic to identify non-zero DCT coefficients from zero DCT coefficients. In so doing, redundant/predictable information can be removed. Additionally, having decomposed the video image into spatial frequencies under DCT means that higher frequencies via their associated DCT coefficients can be coded with less precision than the lower frequencies via their associated DCT coefficients thereby allowing irrelevant information to be removed. Hence, quantization may be generalized as a step to weight the DCT coefficients based on the amount of noise that the human eye can tolerate at each spatial frequency so that a reduced set of coefficients can be generated.
Additionally, MPEG compression also includes additional compression stages such as Alternative Coefficient/Discrete Coefficient (AC/DC) prediction. AC is typically defined as a DCT coefficient for which the frequency in one or both dimensions is non-zero (higher frequency). DC is typically defined as a DCT coefficient for which the frequency is zero (low frequency) in both dimensions. An AC/DC prediction module predicts the AC and DC for the current block based on AC and DC values of adjacent blocks such as an adjacent left top block, a top block, and an adjacent left block. For example, the prediction can be made as follows:
If (|B−A|≧|B−C|) then X=A                else X=Cwhere B is the AC or DC value of the left top block relative to the current block, C is the AC or DC value of the top block relative to the current block, A is the AC or DC value of the left block relative to the current block, and X is the AC or DC value of the current block.        
Such predictions and other features are described in “MPEG-4 Information Technology-Coding of Audio-Visual Objects-Part 2: Visual” ISO/IEC/14496-2:1999 which is herein incorporated by reference in its entirety. Additionally, U.S. Pat. No. 6,341,144 and its continuation U.S. Pat. No. 6,556,625 describes in detail AC/DC predictions and are herein incorporated by reference in their entirety.
Compressed video data is vulnerable to transmission errors. MPEG-4 offers error resilience tools to localize the effects of errors, re-establish synchronization, and recover erroneous data. The end result is more reliable data transmission. These tools include data partition, packetization, and reversible VLC. Data partitioning is designed to localize and isolate the effects of errors by separating and partitioning motion and shape data from texture data in a video packet. A video packet is made up of one or several macroblocks. A frame (a.k.a. Video Object Plane in MPEG-4 terminology) consists of several packets. Each packet starts with markers and the packet header. The data in each packet are encoded independently relative to other packets. Data partition mode in MPEG-4 requires data in any packet to be divided into three parts. Each part consists of bitstream components from all macroblocks in the packet. During data partition mode, a packet size (i.e., the number of data bits in the packet) is limited to 2048 bits for simple profile level-1 video bitstream, 4096 bits for simple profile level-2 video bitstream, and 8192 bits for simple profile level-3 video bitstream.
As a result of the strict packet sizes in data partition mode, there are inherent concerns about packet data overflow during the encoding of a macroblock. To prevent the data loss associated with packet overflow, a macroblock which causes the overflow needs to be re-encoded in a new packet. However, if the AC prediction is always turned on during data partition mode, such re-encoding may cause a change in the AC prediction direction and predicted differences which in turn effects the ZigZag run length of the bitstream. Conversely, if the AC prediction is turned off completely during data partition mode, the compression efficiency is negatively impacted.
Thus, a need exists for a method and apparatus to prevent video packet overflow in a MPEG data partition mode while minimizing the compression efficiency impact and maintaining the video quality.